# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=sireprat
_pkgname=SirepRAT
pkgver=34.b8ef60b
pkgrel=8
pkgdesc='Remote Command Execution as SYSTEM on Windows IoT Core.'
groups=('blackarch' 'blackarch-exploitation' 'blackarch-windows')
arch=('any')
url="https://github.com/SafeBreach-Labs/$_pkgname"
license=('BSD')
depends=('python' 'python-hexdump')
makedepends=('git')
source=("git+https://github.com/SafeBreach-Labs/$_pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $_pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}


package() {
  cd $_pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm -r README.md .gitignore docs/ requirements.txt LICENSE

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python $_pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

